package edu.pku.sei.act.taskStruct;

import org.dom4j.Element;

public class Capability extends Ident{
	private String type;
	private String description;
	private String providerId;
	private String input;
	private String output;
	
	public void addAttrisAndEles(Element element)
	{
		addAttributes(element);
		Element ele;
		ele = element.addElement(TagNames.TYPE);
		ele.addText(type);
		ele = element.addElement(TagNames.DESCRIPTION);
		ele.addText(description);
		ele = element.addElement(TagNames.PROVIDER_ID);
		ele.addText(providerId);
		ele = element.addElement(TagNames.INPUT);
		ele.addText(input);
		ele = element.addElement(TagNames.OUTPUT);
		ele.addText(output);
	}

	public Capability() {
		super();
		setDefaultVal();
	}
	
	public Capability(String id, String name)
	{
		super(id, name);
		setDefaultVal();
	}
	
	public Capability(Element element)
	{
		super();
		setDefaultVal();
		setIdAndName(element);
		
		Element ele;
		
		ele = element.element(TagNames.TYPE);
		if(ele != null) type = ele.getTextTrim();
		
		ele = element.element(TagNames.DESCRIPTION);
		if(ele != null) description = ele.getTextTrim();
		
		ele = element.element(TagNames.PROVIDER_ID);
		if(ele != null) providerId = ele.getTextTrim();
		
		ele = element.element(TagNames.INPUT);
		if(ele != null) input = ele.getTextTrim();
		
		ele = element.element(TagNames.OUTPUT);
		if(ele != null) output = ele.getTextTrim();
		
	}
	
	private void setDefaultVal()
	{
		description = "";
		providerId = "";
		input = "";
		output = "";
	}
	
	public String getType()
	{
		return type;
	}
	
	public String getDescription()
	{
		return description;
	}
	
	public String getProviderId()
	{
		return providerId;
	}
	
	public String getInput()
	{
		return input;
	}
	
	public String getOutput()
	{
		return output;
	}

}
